package de.wittekind.bundesjugendspiele.client.management.urkunden;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import com.itextpdf.text.Anchor;
import com.itextpdf.text.BadElementException;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Chapter;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Element;
import com.itextpdf.text.Font;
import com.itextpdf.text.List;
import com.itextpdf.text.ListItem;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.Section;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;

import de.wittekind.bundesjugendspiele.dummy.DummyRiege;
import de.wittekind.bundesjugendspiele.dummy.DummyRiegenLoader;
import de.wittekind.bundesjugendspiele.server.interfaces.Riege;
import de.wittekind.bundesjugendspiele.server.interfaces.Schueler;

public class Urkunden {
	
	public static void main(String[] args) {
		try {
			Riege r = new DummyRiegenLoader().getRiege(1);
			Schueler schueler = r.getSchueler(1);
			druckeEhrenurkunde(schueler);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	private static final Font catFont = new Font(Font.FontFamily.TIMES_ROMAN,
			22, Font.BOLD);
	private static Font subFont = new Font(Font.FontFamily.TIMES_ROMAN, 13,
			Font.BOLD);

	private static final String FILE = "H:/Ehrenurkunde.pdf";

	public static void druckeEhrenurkunde(Schueler s) {
		try {
			if (s.getPoints() >= 1000) {

				Document document = new Document();
				try {
					PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(FILE));
				} catch (FileNotFoundException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (DocumentException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				document.setPageSize(document.getPageSize().rotate());
				document.open();
				
				PdfWriter writer = null;
				PdfContentByte cb = writer.getDirectContent();

				// we tell the ContentByte we're ready to draw text
				cb.beginText();
			    

				// we draw some text on a certain position
				cb.setTextMatrix(100, 400);
				cb.showText("Text at position 100,400.");
			    

				// we tell the contentByte, we've finished drawing text
				cb.endText();
				document.close();
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}